<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

/**
 * Ketoan_model
 * Build by Phuc Nguyen
 * Contact : nguyenvanphuc0626@gmail.com
 */

class Ketoan_model extends MY_Model{
	
	public function __construct(){
		parent::__construct();
		$this->table_name = 'book_history';
	}
        
        public function export($beginTime,$endTime){
                $this->db->select("tbl.id,tbl.customerID,tbl.booking_id,tbl.booking_place_code, tbl.airline, tbl.lastupdated, tbl.createdTime, tbl.net_fare, tbl.real_fare,tbl.booking,tbl.booking_customer_name,tbl.payment_method,tbl.checker,tbl.owner,usr.firstname,bpl.note AS payment_note, bpl.residual AS sodu");
		$this->db->from($this->table_name . ' AS tbl');
                $this->db->join('users AS usr','usr.id=tbl.owner','inner');
//                $this->db->join('book_payment_log AS bpl','bpl.booking_id=tbl.booking_id AND bpl.owner = 180');
                $this->db->join('book_payment_log AS bpl','bpl.booking_id=tbl.booking_id');
          
                if($beginTime){
                    $this->db->where('tbl.createdTime BETWEEN '.$beginTime. ' AND '.$endTime);
                }
                
                $query = $this->db->get();
//                echo $this->db->last_query();exit;
                return $query->result();
        }
        
}